<template>
	<view class="contina bBtn_p_b140">
		<view class="w" style="height: calc(100% - 20rpx);">
			<scroll-view scroll-y class="scrollView"  v-if="list.length > 0" @scrolltolower="getList">
				<template v-for="(item,idx) in list">
					<view class="card">
						<view class="top" style="display: flex;">
							<view class="ri_text">
								<view class="I item">
									<text style="color: #000000;">{{item.certification.no}}</text>
								</view>
								<view class="II item flex_a_c">
									<text class="label" style="color: #999999;">证书预览</text>
									<view class="val" style="color: #000000;">
										<view class="par_upload">
											<image v-if="item.certification.image" :src="item.certification.image" style="height: 100rpx;width: 100rpx;"></image>
											<image v-else src="../../static/image/phone.png"></image>
										</view>
									</view>
								</view>
								<view class="III item">
									<text class="label" style="color: #999999;">证书类型</text>
									<text class="val" style="color: #000000;">{{item.cer_type == 1?'建筑企业资质':'安全许可证'}}</text>
								</view>
								<view class="IIII item">
									<text class="label" style="color: #999999;">维护时间</text>
									<text class="val" style="color: #000000;">{{item.date}}</text>
								</view>
								<view class="IIIII item">
									<text class="label" style="color: #999999;">维护费用</text>
									<text class="val" style="color: #000000;">￥{{item.fee}}</text>
								</view>
							</view>
						</view>
						<view class="bot">
							<view class="del" @click="del(item.id,idx)">删除</view>
							<view class="se" @click="$fun.toPage('/pagesA/enterprisemainte/form?edit=1&id='+item.id)">查看</view>
						</view>
					</view>
				</template>
			</scroll-view>
			<view class="no" v-else>
				<image src="../../static/image/none.png"></image>
				<view class="em">暂无数据</view>
			</view>
		</view>
		<flooterCom text="新增" @click="toAdd"></flooterCom>
	</view>
</template>

<script>
	import searchCom from "@/compoment/searchCom.vue";
	import flooterCom from "@/compoment/flooterCom.vue"
	export default {
		data() {
			return {
				list: [],
				page: 1,
			}
		},
		onShow() {
			this.getList()
		},
		onHide() {
			this.page=1
			this.list=[]
		},
		components: {
			searchCom,
			flooterCom
		},
		onLoad() {},
		methods: {
			toAdd() {
				uni.navigateTo({
					url: "/pagesA/enterprisemainte/form"
				})
			},
			async getList() {
				let res = await this.$api.corpCertificationMaintenanceApi.list({
					page: this.page
				})
				if (res.list.length) {
					this.list = this.list.concat(res.list)
					this.page++
				}
			},
			del(id, idx) {
				uni.showModal({
					content: '确定删除吗？',
					success: (res) => {
						if (res.confirm) {
							this.$api.corpCertificationMaintenanceApi.del({
								ids: [id]
							}).then(()=>{
								uni.showToast({
									icon:'none',
									title:'删除成功'
								})
								this.list.splice(idx, 1)
							})

						}
					}
				});

			}
		}
	}
</script>

<style lang="scss">
	.contina {
		height: 100%;

		.seach {
			padding: 20rpx 30rpx;
			background-color: #fff;
			// margin-bottom: 20rpx;
			box-sizing: border-box;

			.tabs {
				justify-content: space-between;
				align-items: center;
				font-size: 26rpx;
				font-weight: 400;
				color: #3D3D3D;
				margin-top: 30rpx;
			}
		}

		.scrollView {
			height: 100%;

			.card {
				padding: 30rpx;
				box-sizing: border-box;
				position: relative;
				margin-top: 20rpx;

				.top {
					image {
						width: 160rpx;
						height: 160rpx;
						border-radius: 12rpx;
					}

					.ri_text {
						width: 100%;

						.I {
							font-size: 28rpx;
							font-weight: 400;
							color: #000000;
							border-bottom: 1px solid #EEEEEE;
							padding-bottom: 30rpx;
						}

						.item {
							margin-top: 20rpx;
							font-size: 28rpx;
							display: flex;

							.label {
								flex: .25
							}

							.val {
								flex: .75;
								
								.par_upload {
									width: 100rpx;
									height: 100rpx;
									background-color: #F4F5F7;
									display: flex;
									align-items: center;
									justify-content: center;
									border-radius: 8rpx;
									
									 image{
										 width: 48rpx;
										 height: 48rpx;
									 }
								}
							}
						}
					}
				}

				.bot {
					display: flex;
					align-items: center;
					justify-content: flex-end;
					margin-top: 30rpx;

					.del {
						height: 56rpx;
						background: #FFFFFF;
						border-radius: 50px 50px 50px 50px;
						opacity: 1;
						border: 1px solid #F07878;
						text-align: center;
						line-height: 56rpx;
						font-size: 28rpx;
						color: #FF0000;
						padding: 0 20rpx;
					}

					.se {
						height: 56rpx;
						background: #FFFFFF;
						border-radius: 50px 50px 50px 50px;
						padding: 0 20rpx;
						border: 1px solid #78AEF0;
						line-height: 56rpx;
						text-align: center;
						font-size: 28rpx;
						color: #0074FF;
						margin-left: 20rpx;
					}
				}
			}
		}

		image {
			width: 412rpx;
			height: 284rpx;
			border-radius: 0px 0px 0px 0px;
		}

		.no {
			margin-top: 50rpx;
			display: flex;
			justify-content: center;
			flex-direction: column;
			align-items: center;
			margin-top: 332rpx;

			.em {
				width: 128rpx;
				height: 50rpx;
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #888888;
			}
		}


	}
</style>